{
	received = $1;
	relevant = $3;
	rating = $4;
	r = int(rating/5);
	
	count[r,relevant] += received;
	countTotal[relevant] += received;

	if (received > max_received) max_received = received;
	if (relevant > max_relevant) max_relevant = relevant;
	if (r > max_r) max_r = r;
}

END {
	for (relevant=1; relevant<max_relevant; relevant++) {
#		for (received=0; received<max_received; received++) {
#			print relevant, received, count[received,relevant], countTotal[relevant];
#		}
		for (r=0; r<max_r; r++) {
			print 5*r, relevant, count[r,relevant], countTotal[relevant];
		}
	}
}